game
.L00 ;  include fixed_point_math.asm

.L01 ;  rem pikachu Chase

.L02 ;  rem A fun game that may help you learn batari Basic!

.L03 ;  rem

.
 ; 

.L04 ;  rem timed game, 16 levels

.L05 ;  rem Each level lasts about one minute

.L06 ;  rem you must score 1000 points to move on

.L07 ;  rem COLOR/BW switch selects joystick or DC

.L08 ;  rem left difficulty A=stop on collision; B=slow down on collision

.L09 ;  rem right difficulty A=L/R border; B=no border

.
 ; 

.L010 ;  set kernel_options no_blank_lines player1colors

.L011 ;  playfieldpos = 4

	LDA #4
	STA playfieldpos
.L012 ;  set smartbranching on

.
 ; 

.L013 ;  dim carpos = a

.L014 ;  dim turndelay = b

.L015 ;  dim collcount = b

.L016 ;  dim carframe = c

.L017 ;  dim gamebits = e

.L018 ;  dim velocity = f.f

.L019 ;  dim xvelocity = g.g

.L020 ;  dim yvelocity = h.h

.L021 ;  dim tempvel = i.i

.L022 ;  dim finalxvelocity = l.l

.L023 ;  dim finalyvelocity = m.m

.
 ; 

.L024 ;  dim p0x = player0x.j

.L025 ;  dim p0y = player0y.k

.L026 ;  dim last = n

.
 ; 

.L027 ;  dim scadd = o

.L028 ;  dim timer1 = p

.L029 ;  dim timer2 = q

.L030 ;  dim level = q

.L031 ;  rem level bits

.L032 ;  rem bit 0: pikachu speed (slow/fast)

.L033 ;  rem bit 1: pikachu movement (random/run away)

.L034 ;  rem bit 2: car speed (slow/fast)

.L035 ;  rem bit 3: road surface (pavement/ice)

.
 ; 

.L036 ;  dim tempvel8 = temp1.temp2

.
 ; 

.L037 ;  dim pikachuvel = temp5.temp6

.L038 ;  dim pikachuxvel = r

.L039 ;  dim pikachuyvel = s

.L040 ;  dim pikachufinalxvel = t

.L041 ;  dim pikachufinalyvel = u

.L042 ;  dim pikachuxpos = player1x.v

.L043 ;  dim pikachuypos = player1y.w

.
 ; 

.L044 ;  dim sc1 = score

.L045 ;  dim sc2 = score + 1

.
 ; 

.L046 ;  rem 

.L047 ;  rem velocity doesn't change when direction changes

.L048 ;  rem xvelocity and yvelocity change

.L049 ;  rem they change instantly when velocity <= 0.5 max

.L050 ;  rem they change gradually when velocity > 0.5 max

.
 ; 

.L051 ;  carpos  =  4

	LDA #4
	STA carpos
.L052 ;  rem turndelay = 0

.L053 ;  player0x  =  40  :  player0y  =  40

	LDA #40
	STA player0x
	STA player0y
.startLoop
 ; startLoop

.L054 ;  if turndelay{1} then player1: 

	LDA turndelay
	AND #2
	BEQ .skipL054
.condpart0
	LDA #<player0then_1

	STA player1pointerlo
	LDA #>player0then_1

	STA player1pointerhi
	LDA #8
	STA player1height
.skipL054
.L055 ;  if !turndelay{1} then player1:

	LDA turndelay
	AND #2
	BNE .skipL055
.condpart1
	LDA #<player1then_1

	STA player1pointerlo
	LDA #>player1then_1

	STA player1pointerhi
	LDA #8
	STA player1height
.skipL055
.
 ; 

.L056 ;  player1color:

	LDA #<playercolorL056_1

	STA player1color
	LDA #>playercolorL056_1

	STA player1color+1
.L057 ;  scorecolor = 30

	LDA #30
	STA scorecolor
.L058 ;  if switchreset then reboot

 lda #1
 bit SWCHB
	BNE .skipL058
.condpart2
	JMP ($FFFC)
.skipL058
.L059 ;  if switchrightb then PF0 = 0 else PF0 = 63

 lda #$80
 bit SWCHB
	BNE .skipL059
.condpart3
	LDA #0
	STA PF0
 jmp .skipelse0
.skipL059
	LDA #63
	STA PF0
.skipelse0
.L060 ;  COLUPF =  ( level  *  16 )  ^ 244

; complex statement detected
	LDA level
	asl
	asl
	asl
	asl
	EOR #244
	STA COLUPF
.L061 ;  if gamebits{7} then gamerunning

	BIT gamebits
 if ((* - .gamerunning) < 127) && ((* - .gamerunning) > -128)
	bmi .gamerunning
 else
	bpl .0skipgamerunning
	jmp .gamerunning
.0skipgamerunning
 endif
.L062 ;  if !joy0fire then timer1 = timer1 + 1

 lda #$80
 bit INPT4
	BEQ .skipL062
.condpart4
	INC timer1
.skipL062
.L063 ;  if timer1 = 0 then nostartgame

	LDA timer1
	CMP #0
 if ((* - .nostartgame) < 127) && ((* - .nostartgame) > -128)
	BEQ .nostartgame
 else
	bne .1skipnostartgame
	jmp .nostartgame
.1skipnostartgame
 endif
.L064 ;  if joy0fire then score = 0 : timer1 = 0 : timer2 = 0 : gamebits{7} = 1 : pfclear

 lda #$80
 bit INPT4
	BNE .skipL064
.condpart5
	LDA #$00
	STA score+2
	LDA #$00
	STA score+1
	LDA #$00
	STA score
	LDA #0
	STA timer1
	STA timer2
	LDA gamebits
	ORA #128
	STA gamebits
	LDA #0
 jsr pfclear
.skipL064
.nostartgame
 ; nostartgame

.L065 ;  AUDV0 = 0 : AUDV1 = 0 : goto hitwall

	LDA #0
	STA AUDV0
	STA AUDV1
 jmp .hitwall

.gamerunning
 ; gamerunning

.L066 ;  timer1 = timer1 + 1 : if timer1 = 0 then timer2 = timer2 + $10

	INC timer1
	LDA timer1
	CMP #0
     BNE .skipL066
.condpart6
	LDA timer2
	CLC
	ADC #$10
	STA timer2
.skipL066
.L067 ;  if timer2 < $C0 then notendlevel

	LDA timer2
	CMP #$C0
 if ((* - .notendlevel) < 127) && ((* - .notendlevel) > -128)
	bcc .notendlevel
 else
	bcs .2skipnotendlevel
	jmp .notendlevel
.2skipnotendlevel
 endif
.L068 ;  temp1 = level  &  $0F

	LDA level
	AND #$0F
	STA temp1
.L069 ;  temp2 = sc1 * 16 + sc2 / 16

; complex statement detected
	LDA sc1
	asl
	asl
	asl
	asl
	PHA
	LDA sc2
	lsr
	lsr
	lsr
	lsr
	TSX
	INX
	TXS
	CLC
	ADC $100,x
	STA temp2
.L070 ;  temp1 = level  &  $0F

	LDA level
	AND #$0F
	STA temp1
.L071 ;  if temp2 < gonextlevel[temp1]  &&  timer1{5} then scorecolor = 64

	LDA temp2
	LDX temp1
	CMP gonextlevel,x
     BCS .skipL071
.condpart7
	LDA timer1
	AND #32
	BEQ .skip7then
.condpart8
	LDA #64
	STA scorecolor
.skip7then
.skipL071
.L072 ;  if timer2 < $F0 then notendlevel

	LDA timer2
	CMP #$F0
 if ((* - .notendlevel) < 127) && ((* - .notendlevel) > -128)
	bcc .notendlevel
 else
	bcs .3skipnotendlevel
	jmp .notendlevel
.3skipnotendlevel
 endif
.L073 ;  if temp2 >= gonextlevel[temp1] then level = level + $11 : pfclear else gamebits{7} = 0

	LDA temp2
	LDX temp1
	CMP gonextlevel,x
     BCC .skipL073
.condpart9
	LDA level
	CLC
	ADC #$11
	STA level
	LDA #0
 jsr pfclear
 jmp .skipelse1
.skipL073
	LDA gamebits
	AND #127
	STA gamebits
.skipelse1
.notendlevel
 ; notendlevel

.L074 ;  gosub movepikachu

 jsr .movepikachu

.L075 ;  if collcount < 16 then skipcrashsound

	LDA collcount
	CMP #16
 if ((* - .skipcrashsound) < 127) && ((* - .skipcrashsound) > -128)
	bcc .skipcrashsound
 else
	bcs .4skipskipcrashsound
	jmp .skipcrashsound
.4skipskipcrashsound
 endif
.L076 ;  collcount = collcount - 16

	LDA collcount
	SEC
	SBC #16
	STA collcount
.L077 ;  AUDV0 = collcount / 16

	LDA collcount
	lsr
	lsr
	lsr
	lsr
	STA AUDV0
.L078 ;  AUDC0 = 8

	LDA #8
	STA AUDC0
.L079 ;  if collcount{3} then AUDF0 =  ( collcount & rand )  / 8 else AUDF0 = 17

	LDA collcount
	AND #8
	BEQ .skipL079
.condpart10
; complex statement detected
	LDA collcount
	AND rand
	lsr
	lsr
	lsr
	STA AUDF0
 jmp .skipelse2
.skipL079
	LDA #17
	STA AUDF0
.skipelse2
.L080 ;  goto skipenginesound

 jmp .skipenginesound

.skipcrashsound
 ; skipcrashsound

.L081 ;  collcount{3} = 0

	LDA collcount
	AND #247
	STA collcount
.L082 ;  AUDV0 = 10 : AUDC0 = 2

	LDA #10
	STA AUDV0
	LDA #2
	STA AUDC0
.L083 ;  AUDF0 = 18 - f / 4 : if f > 67 then AUDF0 = 1

; complex statement detected
	LDA #18
	PHA
	LDA f
	lsr
	lsr
	TAY
	PLA
	TSX
	STY $00,x
	SEC
	SBC $100,x
	STA AUDF0
	LDA #67
	CMP f
     BCS .skipL083
.condpart11
	LDA #1
	STA AUDF0
.skipL083
.skipenginesound
 ; skipenginesound

.
 ; 

.L084 ;  if joy0fire then velocity = velocity + 0.0625 : goto nomove1

 lda #$80
 bit INPT4
	BNE .skipL084
.condpart12
	CLC
	LDA velocity
	ADC #1
	STA velocity
 jmp .nomove1

.skipL084
.L085 ;  gamebits = gamebits ^ %00000100

	LDA gamebits
	EOR #%00000100
	STA gamebits
.L086 ;  if gamebits{2} then nomove1

	LDA gamebits
	AND #4
 if ((* - .nomove1) < 127) && ((* - .nomove1) > -128)
	BNE .nomove1
 else
	beq .5skipnomove1
	jmp .nomove1
.5skipnomove1
 endif
.L087 ;  velocity = velocity - 0.0625

	SEC
	LDA velocity
	SBC #1
	STA velocity
.nomove1
 ; nomove1

.L088 ;  if level{2} then temp1 = 96 else temp1 = 64

	LDA level
	AND #4
	BEQ .skipL088
.condpart13
	LDA #96
	STA temp1
 jmp .skipelse3
.skipL088
	LDA #64
	STA temp1
.skipelse3
.L089 ;  if gamebits{4} then temp1 = 80

	LDA gamebits
	AND #16
	BEQ .skipL089
.condpart14
	LDA #80
	STA temp1
.skipL089
.L090 ;  if velocity  >  temp1  &&  velocity  <  192 then velocity = velocity - 0.0625

	LDA temp1
	CMP velocity
     BCS .skipL090
.condpart15
	LDA velocity
	CMP #192
     BCS .skip15then
.condpart16
	SEC
	LDA velocity
	SBC #1
	STA velocity
.skip15then
.skipL090
.L091 ;  if velocity > 240 then velocity = 0

	LDA #240
	CMP velocity
     BCS .skipL091
.condpart17
	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA velocity
.skipL091
.
 ; 

.L092 ;  if !level{3} then COLUBK = 0 else COLUBK = 154

	LDA level
	AND #8
	BNE .skipL092
.condpart18
	LDA #0
	STA COLUBK
 jmp .skipelse4
.skipL092
	LDA #154
	STA COLUBK
.skipelse4
.
 ; 

.L093 ;  on carpos goto a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15

	LDX carpos
	LDA .L093jumptablehi,x
	PHA
	LDA .L093jumptablelo,x
	PHA
	RTS
.L093jumptablehi
	.byte >(.a0-1)
	.byte >(.a1-1)
	.byte >(.a2-1)
	.byte >(.a3-1)
	.byte >(.a4-1)
	.byte >(.a5-1)
	.byte >(.a6-1)
	.byte >(.a7-1)
	.byte >(.a8-1)
	.byte >(.a9-1)
	.byte >(.a10-1)
	.byte >(.a11-1)
	.byte >(.a12-1)
	.byte >(.a13-1)
	.byte >(.a14-1)
	.byte >(.a15-1)
.L093jumptablelo
	.byte <(.a0-1)
	.byte <(.a1-1)
	.byte <(.a2-1)
	.byte <(.a3-1)
	.byte <(.a4-1)
	.byte <(.a5-1)
	.byte <(.a6-1)
	.byte <(.a7-1)
	.byte <(.a8-1)
	.byte <(.a9-1)
	.byte <(.a10-1)
	.byte <(.a11-1)
	.byte <(.a12-1)
	.byte <(.a13-1)
	.byte <(.a14-1)
	.byte <(.a15-1)
.a0 ; a0 rem 0 (due north, or up)

.L094 ;  xvelocity = 0 : yvelocity = 0 - velocity

	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA xvelocity
	LDA #0
	SEC
	SBC velocity
	STA yvelocity
.L095 ;  goto skipskid

 jmp .skipskid

.a1 ; a1 rem 22.5

.L096 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L097 ;  xvelocity = tempvel : yvelocity = tempvel - velocity

	LDA tempvel
	STA xvelocity
	LDA tempvel
	SEC
	SBC velocity
	STA yvelocity
.L098 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L099 ;  xvelocity = xvelocity + tempvel

	LDA xvelocity
	CLC
	ADC tempvel
	STA xvelocity
.L0100 ;  goto skipskid

 jmp .skipskid

.a2 ; a2 rem 45

.L0101 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0102 ;  xvelocity = velocity / 2

	LDA velocity
	lsr
	STA xvelocity
.L0103 ;  if xvelocity{7} then xvelocity = xvelocity  |  %10000000

	BIT xvelocity
	BPL .skipL0103
.condpart19
	LDA xvelocity
	ORA #%10000000
	STA xvelocity
.skipL0103
.L0104 ;  xvelocity = xvelocity + tempvel : yvelocity = 0 - xvelocity

	LDA xvelocity
	CLC
	ADC tempvel
	STA xvelocity
	LDA #0
	SEC
	SBC xvelocity
	STA yvelocity
.L0105 ;  goto skipskid

 jmp .skipskid

.a3 ; a3 rem 67.5

.L0106 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0107 ;  xvelocity = velocity - tempvel : yvelocity = 0 - tempvel

	LDA velocity
	SEC
	SBC tempvel
	STA xvelocity
	LDA #0
	SEC
	SBC tempvel
	STA yvelocity
.L0108 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0109 ;  yvelocity = yvelocity - tempvel

	LDA yvelocity
	SEC
	SBC tempvel
	STA yvelocity
.L0110 ;  goto skipskid

 jmp .skipskid

.a4 ; a4 rem 90

.L0111 ;  xvelocity = velocity : yvelocity = 0

	LDA velocity
	STA xvelocity
	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA yvelocity
.L0112 ;  goto skipskid

 jmp .skipskid

.a5 ; a5 rem 112.5

.L0113 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0114 ;  xvelocity = velocity - tempvel : yvelocity = tempvel

	LDA velocity
	SEC
	SBC tempvel
	STA xvelocity
	LDA tempvel
	STA yvelocity
.L0115 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0116 ;  yvelocity = yvelocity + tempvel

	LDA yvelocity
	CLC
	ADC tempvel
	STA yvelocity
.L0117 ;  goto skipskid

 jmp .skipskid

.a6 ; a6 rem 135

.L0118 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0119 ;  xvelocity = velocity / 2

	LDA velocity
	lsr
	STA xvelocity
.L0120 ;  if xvelocity{7} then xvelocity = xvelocity  |  %10000000

	BIT xvelocity
	BPL .skipL0120
.condpart20
	LDA xvelocity
	ORA #%10000000
	STA xvelocity
.skipL0120
.L0121 ;  xvelocity = xvelocity + tempvel : yvelocity = xvelocity

	LDA xvelocity
	CLC
	ADC tempvel
	STA xvelocity
	LDA xvelocity
	STA yvelocity
.L0122 ;  goto skipskid

 jmp .skipskid

.a7 ; a7 rem 157.5

.L0123 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0124 ;  xvelocity = tempvel : yvelocity = velocity - tempvel

	LDA tempvel
	STA xvelocity
	LDA velocity
	SEC
	SBC tempvel
	STA yvelocity
.L0125 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0126 ;  xvelocity = xvelocity + tempvel

	LDA xvelocity
	CLC
	ADC tempvel
	STA xvelocity
.L0127 ;  goto skipskid

 jmp .skipskid

.a8 ; a8 rem 180

.L0128 ;  xvelocity = 0 : yvelocity = velocity

	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA xvelocity
	LDA velocity
	STA yvelocity
.L0129 ;  goto skipskid

 jmp .skipskid

.a9 ; a9 rem 202.5

.L0130 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0131 ;  xvelocity = 0 - tempvel : yvelocity = velocity - tempvel

	LDA #0
	SEC
	SBC tempvel
	STA xvelocity
	LDA velocity
	SEC
	SBC tempvel
	STA yvelocity
.L0132 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0133 ;  xvelocity = xvelocity - tempvel

	LDA xvelocity
	SEC
	SBC tempvel
	STA xvelocity
.L0134 ;  goto skipskid

 jmp .skipskid

.a10 ; a10 rem 225

.L0135 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0136 ;  xvelocity = velocity / 2

	LDA velocity
	lsr
	STA xvelocity
.L0137 ;  yvelocity = tempvel + xvelocity : xvelocity = 0 - xvelocity

	LDA tempvel
	CLC
	ADC xvelocity
	STA yvelocity
	LDA #0
	SEC
	SBC xvelocity
	STA xvelocity
.L0138 ;  goto skipskid

 jmp .skipskid

.a11 ; a11 rem 247.5

.L0139 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0140 ;  xvelocity = tempvel - velocity : yvelocity = tempvel

	LDA tempvel
	SEC
	SBC velocity
	STA xvelocity
	LDA tempvel
	STA yvelocity
.L0141 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0142 ;  yvelocity = yvelocity + tempvel

	LDA yvelocity
	CLC
	ADC tempvel
	STA yvelocity
.L0143 ;  goto skipskid

 jmp .skipskid

.a12 ; a12 rem 270

.L0144 ;  xvelocity = 0 - velocity : yvelocity = 0

	LDA #0
	SEC
	SBC velocity
	STA xvelocity
	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA yvelocity
.L0145 ;  goto skipskid

 jmp .skipskid

.a13 ; a13 rem 292.5

.L0146 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0147 ;  xvelocity = tempvel - velocity : yvelocity = 0 - tempvel

	LDA tempvel
	SEC
	SBC velocity
	STA xvelocity
	LDA #0
	SEC
	SBC tempvel
	STA yvelocity
.L0148 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0149 ;  yvelocity = yvelocity - tempvel

	LDA yvelocity
	SEC
	SBC tempvel
	STA yvelocity
.L0150 ;  goto skipskid

 jmp .skipskid

.a14 ; a14 rem 315

.L0151 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0152 ;  xvelocity = velocity / 2

	LDA velocity
	lsr
	STA xvelocity
.L0153 ;  xvelocity = tempvel + xvelocity : xvelocity = 0 - xvelocity : yvelocity = xvelocity

	LDA tempvel
	CLC
	ADC xvelocity
	STA xvelocity
	LDA #0
	SEC
	SBC xvelocity
	STA xvelocity
	LDA xvelocity
	STA yvelocity
.L0154 ;  goto skipskid

 jmp .skipskid

.a15 ; a15 rem 337.5 

.L0155 ;  tempvel = velocity / 8

	LDA velocity
	lsr
	lsr
	lsr
	STA tempvel
.L0156 ;  xvelocity = 0 - tempvel : yvelocity = tempvel - velocity

	LDA #0
	SEC
	SBC tempvel
	STA xvelocity
	LDA tempvel
	SEC
	SBC velocity
	STA yvelocity
.L0157 ;  tempvel = velocity / 4

	LDA velocity
	lsr
	lsr
	STA tempvel
.L0158 ;  xvelocity = xvelocity - tempvel

	LDA xvelocity
	SEC
	SBC tempvel
	STA xvelocity
.
 ; 

.
 ; 

.skipskid
 ; skipskid

.L0159 ;  if velocity{7} then reboot

	BIT velocity
	BPL .skipL0159
.condpart21
	JMP ($FFFC)
.skipL0159
.L0160 ;  if !gamebits{0} then finalxvelocity = xvelocity : finalyvelocity = yvelocity : AUDV1 = 0 : goto noskid else skid

	LDA gamebits
	LSR
	BCS .skipL0160
.condpart22
	LDA xvelocity
	STA finalxvelocity
	LDA yvelocity
	STA finalyvelocity
	LDA #0
	STA AUDV1
 jmp .noskid
.skipL0160
 jmp .skid

.skipelse5
.L0161 ;  if velocity < 32 then finalxvelocity = xvelocity : finalyvelocity = yvelocity : AUDV1 = 0 : goto noskid

	LDA velocity
	CMP #32
     BCS .skipL0161
.condpart23
	LDA xvelocity
	STA finalxvelocity
	LDA yvelocity
	STA finalyvelocity
	LDA #0
	STA AUDV1
 jmp .noskid

.skipL0161
.L0162 ;  if finalxvelocity  =  xvelocity  &&  finalyvelocity  =  yvelocity then AUDV1 = 0 : goto noskid

	LDA finalxvelocity
	CMP xvelocity
     BNE .skipL0162
.condpart24
	LDA finalyvelocity
	CMP yvelocity
     BNE .skip24then
.condpart25
	LDA #0
	STA AUDV1
 jmp .noskid

.skip24then
.skipL0162
.
 ; 

.skid
 ; skid

.L0163 ;  rem lost traction...skid

.L0164 ;  gamebits{5} = 0

	LDA gamebits
	AND #223
	STA gamebits
.L0165 ;  gamebits{6} = 0

	LDA gamebits
	AND #191
	STA gamebits
.
 ; 

.L0166 ;  if xvelocity > 127  &&  finalxvelocity > 127 then bothxneg

	LDA #127
	CMP xvelocity
     BCS .skipL0166
.condpart26
	LDA #127
	CMP finalxvelocity
 if ((* - .bothxneg) < 127) && ((* - .bothxneg) > -128)
	bcc .bothxneg
 else
	bcs .6skipbothxneg
	jmp .bothxneg
.6skipbothxneg
 endif
.skipL0166
.L0167 ;  if xvelocity < 128  &&  finalxvelocity < 128 then bothxpos

	LDA xvelocity
	CMP #128
     BCS .skipL0167
.condpart27
	LDA finalxvelocity
	CMP #128
 if ((* - .bothxpos) < 127) && ((* - .bothxpos) > -128)
	bcc .bothxpos
 else
	bcs .7skipbothxpos
	jmp .bothxpos
.7skipbothxpos
 endif
.skipL0167
.L0168 ;  if xvelocity > 127 then subx else addx

	LDA #127
	CMP xvelocity
 if ((* - .subx) < 127) && ((* - .subx) > -128)
	bcc .subx
 else
	bcs .8skipsubx
	jmp .subx
.8skipsubx
 endif
 jmp .addx

.skipelse6
.bothxneg
 ; bothxneg

.L0169 ;  temp1 =  ( finalxvelocity  ^  xvelocity )   &  %11111100

; complex statement detected
	LDA finalxvelocity
	EOR xvelocity
	AND #%11111100
	STA temp1
.L0170 ;  if temp1 = 0 then finalxvelocity = xvelocity : gamebits{5} = 1 : goto checky

	LDA temp1
	CMP #0
     BNE .skipL0170
.condpart28
	LDA xvelocity
	STA finalxvelocity
	LDA gamebits
	ORA #32
	STA gamebits
 jmp .checky

.skipL0170
.L0171 ;  if finalxvelocity < xvelocity then addx

	LDA finalxvelocity
	CMP xvelocity
 if ((* - .addx) < 127) && ((* - .addx) > -128)
	bcc .addx
 else
	bcs .9skipaddx
	jmp .addx
.9skipaddx
 endif
.subx
 ; subx

.L0172 ;  if level{3} then finalxvelocity = finalxvelocity - 0.0625 else finalxvelocity = finalxvelocity - 0.3

	LDA level
	AND #8
	BEQ .skipL0172
.condpart29
	SEC
	LDA finalxvelocity
	SBC #1
	STA finalxvelocity
 jmp .skipelse7
.skipL0172
	SEC
	LDA finalxvelocity
	SBC #4
	STA finalxvelocity
.skipelse7
.L0173 ;  goto checky

 jmp .checky

.
 ; 

.bothxpos
 ; bothxpos

.L0174 ;  temp1 =  ( finalxvelocity  ^  xvelocity )   &  %11111100

; complex statement detected
	LDA finalxvelocity
	EOR xvelocity
	AND #%11111100
	STA temp1
.L0175 ;  if temp1 = 0 then finalxvelocity = xvelocity : gamebits{5} = 1 : goto checky

	LDA temp1
	CMP #0
     BNE .skipL0175
.condpart30
	LDA xvelocity
	STA finalxvelocity
	LDA gamebits
	ORA #32
	STA gamebits
 jmp .checky

.skipL0175
.L0176 ;  if finalxvelocity > xvelocity then subx

	LDA xvelocity
	CMP finalxvelocity
 if ((* - .subx) < 127) && ((* - .subx) > -128)
	bcc .subx
 else
	bcs .10skipsubx
	jmp .subx
.10skipsubx
 endif
.addx
 ; addx

.L0177 ;  if level{3} then finalxvelocity = finalxvelocity + 0.0625 else finalxvelocity = finalxvelocity + 0.3

	LDA level
	AND #8
	BEQ .skipL0177
.condpart31
	CLC
	LDA finalxvelocity
	ADC #1
	STA finalxvelocity
 jmp .skipelse8
.skipL0177
	CLC
	LDA finalxvelocity
	ADC #4
	STA finalxvelocity
.skipelse8
.
 ; 

.
 ; 

.checky
 ; checky

.L0178 ;  if yvelocity > 127  &&  finalyvelocity > 127 then bothyneg

	LDA #127
	CMP yvelocity
     BCS .skipL0178
.condpart32
	LDA #127
	CMP finalyvelocity
 if ((* - .bothyneg) < 127) && ((* - .bothyneg) > -128)
	bcc .bothyneg
 else
	bcs .11skipbothyneg
	jmp .bothyneg
.11skipbothyneg
 endif
.skipL0178
.L0179 ;  if yvelocity < 128  &&  finalyvelocity < 128 then bothypos

	LDA yvelocity
	CMP #128
     BCS .skipL0179
.condpart33
	LDA finalyvelocity
	CMP #128
 if ((* - .bothypos) < 127) && ((* - .bothypos) > -128)
	bcc .bothypos
 else
	bcs .12skipbothypos
	jmp .bothypos
.12skipbothypos
 endif
.skipL0179
.L0180 ;  if yvelocity > 127 then suby else addy

	LDA #127
	CMP yvelocity
 if ((* - .suby) < 127) && ((* - .suby) > -128)
	bcc .suby
 else
	bcs .13skipsuby
	jmp .suby
.13skipsuby
 endif
 jmp .addy

.skipelse9
.bothyneg
 ; bothyneg

.L0181 ;  temp1 =  ( finalyvelocity  ^  yvelocity )   &  %11111100

; complex statement detected
	LDA finalyvelocity
	EOR yvelocity
	AND #%11111100
	STA temp1
.L0182 ;  if temp1 = 0 then finalyvelocity = yvelocity : gamebits{6} = 1 : goto doneskid

	LDA temp1
	CMP #0
     BNE .skipL0182
.condpart34
	LDA yvelocity
	STA finalyvelocity
	LDA gamebits
	ORA #64
	STA gamebits
 jmp .doneskid

.skipL0182
.L0183 ;  if finalyvelocity < yvelocity then addy

	LDA finalyvelocity
	CMP yvelocity
 if ((* - .addy) < 127) && ((* - .addy) > -128)
	bcc .addy
 else
	bcs .14skipaddy
	jmp .addy
.14skipaddy
 endif
.suby
 ; suby

.L0184 ;  if level{3} then finalyvelocity = finalyvelocity - 0.0625 else finalyvelocity = finalyvelocity - 0.3

	LDA level
	AND #8
	BEQ .skipL0184
.condpart35
	SEC
	LDA finalyvelocity
	SBC #1
	STA finalyvelocity
 jmp .skipelse10
.skipL0184
	SEC
	LDA finalyvelocity
	SBC #4
	STA finalyvelocity
.skipelse10
.L0185 ;  goto doneskid

 jmp .doneskid

.
 ; 

.bothypos
 ; bothypos

.L0186 ;  temp1 =  ( finalyvelocity  ^  yvelocity )   &  %11111100

; complex statement detected
	LDA finalyvelocity
	EOR yvelocity
	AND #%11111100
	STA temp1
.L0187 ;  if temp1 = 0 then finalyvelocity = yvelocity : gamebits{6} = 1 : goto doneskid

	LDA temp1
	CMP #0
     BNE .skipL0187
.condpart36
	LDA yvelocity
	STA finalyvelocity
	LDA gamebits
	ORA #64
	STA gamebits
 jmp .doneskid

.skipL0187
.L0188 ;  if finalyvelocity > yvelocity then suby

	LDA yvelocity
	CMP finalyvelocity
 if ((* - .suby) < 127) && ((* - .suby) > -128)
	bcc .suby
 else
	bcs .15skipsuby
	jmp .suby
.15skipsuby
 endif
.addy
 ; addy

.L0189 ;  if level{3} then finalyvelocity = finalyvelocity + 0.0625 else finalyvelocity = finalyvelocity + 0.3

	LDA level
	AND #8
	BEQ .skipL0189
.condpart37
	CLC
	LDA finalyvelocity
	ADC #1
	STA finalyvelocity
 jmp .skipelse11
.skipL0189
	CLC
	LDA finalyvelocity
	ADC #4
	STA finalyvelocity
.skipelse11
.
 ; 

.doneskid
 ; doneskid

.L0190 ;  if gamebits{5}  &&  gamebits{6} then gamebits{0} = 0 : AUDV1 = 0 : goto noskid

	LDA gamebits
	AND #32
	BEQ .skipL0190
.condpart38
	BIT gamebits
	BVC .skip38then
.condpart39
	LDA gamebits
	AND #254
	STA gamebits
	LDA #0
	STA AUDV1
 jmp .noskid

.skip38then
.skipL0190
.
 ; 

.L0191 ;  rem skid sound

.L0192 ;  temp6 = rand

 jsr randomize
	STA temp6
.L0193 ;  if temp1{6} then AUDV1 = 9

	BIT temp1
	BVC .skipL0193
.condpart40
	LDA #9
	STA AUDV1
.skipL0193
.
 ; 

.L0194 ;  rem if temp6{0} then AUDC1=3:AUDF1=0 else AUDC1=3:AUDF1=1

.L0195 ;  rem AUDV1=temp6&3

.L0196 ;  if level{3} then temp1 = 8 else temp1 = 20

	LDA level
	AND #8
	BEQ .skipL0196
.condpart41
	LDA #8
	STA temp1
 jmp .skipelse12
.skipL0196
	LDA #20
	STA temp1
.skipelse12
.L0197 ;  AUDC1 = temp1

	LDA temp1
	STA AUDC1
.L0198 ;  if temp6{0} then AUDF1 = temp1 + 4 else AUDF1 = temp1 + 5

	LDA temp6
	LSR
	BCC .skipL0198
.condpart42
	LDA temp1
	CLC
	ADC #4
	STA AUDF1
 jmp .skipelse13
.skipL0198
	LDA temp1
	CLC
	ADC #5
	STA AUDF1
.skipelse13
.
 ; 

.
 ; 

.noskid
 ; noskid

.L0199 ;  rem gamebits=gamebits^%00000010

.L0200 ;  rem if gamebits{1} then donotadd

.
 ; 

.L0201 ;  tempvel8 = finalxvelocity

	LDA finalxvelocity
  JSR Assign44to88
  STX temp2
	STA tempvel8
.L0202 ;  asm

 lda temp1

 asl

 ror temp1

 ror temp2

.L0203 ;  p0x = p0x + tempvel8

	LDA j
	CLC 
	ADC temp2
	STA j
	LDA p0x
	ADC tempvel8
	STA p0x
.
 ; 

.L0204 ;  tempvel8 = finalyvelocity

	LDA finalyvelocity
  JSR Assign44to88
  STX temp2
	STA tempvel8
.L0205 ;  asm

 lda temp1

 asl

 ror temp1

 ror temp2

.
 ; 

.L0206 ;  p0y = p0y + tempvel8

	LDA k
	CLC 
	ADC temp2
	STA k
	LDA p0y
	ADC tempvel8
	STA p0y
.donotadd
 ; donotadd

.
 ; 

.L0207 ;  if player0x > 200 then player0x = 159 : goto wrap

	LDA #200
	CMP player0x
     BCS .skipL0207
.condpart43
	LDA #159
	STA player0x
 jmp .wrap

.skipL0207
.L0208 ;  if player0x > 159 then player0x = 0

	LDA #159
	CMP player0x
     BCS .skipL0208
.condpart44
	LDA #0
	STA player0x
.skipL0208
.wrap
 ; wrap

.L0209 ;  if player0y > 200 then player0y = 96

	LDA #200
	CMP player0y
     BCS .skipL0209
.condpart45
	LDA #96
	STA player0y
.skipL0209
.L0210 ;  if player0y > 96 then player0y = 0

	LDA #96
	CMP player0y
     BCS .skipL0210
.condpart46
	LDA #0
	STA player0y
.skipL0210
.
 ; 

.L0211 ;  if switchbw then driving

 lda #8
 bit SWCHB
 if ((* - .driving) < 127) && ((* - .driving) > -128)
	BEQ .driving
 else
	bne .16skipdriving
	jmp .driving
.16skipdriving
 endif
.L0212 ;  turndelay  =  turndelay  +  1

	INC turndelay
.L0213 ;  turndelay  =  turndelay  &  %11111011

	LDA turndelay
	AND #%11111011
	STA turndelay
.L0214 ;  temp1 = turndelay & 3

	LDA turndelay
	AND #3
	STA temp1
.L0215 ;  if temp1  <>  0 goto SameFrame

	LDA temp1
	CMP #0
 if ((* - .SameFrame) < 127) && ((* - .SameFrame) > -128)
	BNE .SameFrame
 else
	beq .17skipSameFrame
	jmp .SameFrame
.17skipSameFrame
 endif
.
 ; 

.
 ; 

.L0216 ;  if joy0left then carpos = carpos - 1 : gamebits{0} = 1

 lda #$40
 bit SWCHA
	BNE .skipL0216
.condpart47
	DEC carpos
	LDA gamebits
	ORA #1
	STA gamebits
.skipL0216
.L0217 ;  if joy0right then carpos = carpos + 1 : gamebits{0} = 1

 lda #$80
 bit SWCHA
	BNE .skipL0217
.condpart48
	INC carpos
	LDA gamebits
	ORA #1
	STA gamebits
.skipL0217
.L0218 ;  goto nodriving

 jmp .nodriving

.
 ; 

.driving ; driving rem read driving controller

.L0219 ;  temp1 = SWCHA  &  %00110000

	LDA SWCHA
	AND #%00110000
	STA temp1
.L0220 ;  temp1 = temp1 / 16

	LDA temp1
	lsr
	lsr
	lsr
	lsr
	STA temp1
.L0221 ;  on last goto d00 d01 d10 d11

	LDX last
	LDA .L0221jumptablehi,x
	PHA
	LDA .L0221jumptablelo,x
	PHA
	RTS
.L0221jumptablehi
	.byte >(.d00-1)
	.byte >(.d01-1)
	.byte >(.d10-1)
	.byte >(.d11-1)
.L0221jumptablelo
	.byte <(.d00-1)
	.byte <(.d01-1)
	.byte <(.d10-1)
	.byte <(.d11-1)
.d00 ; d00 on temp1 goto nomove left right nomove

	LDX temp1
	LDA .d00jumptablehi,x
	PHA
	LDA .d00jumptablelo,x
	PHA
	RTS
.d00jumptablehi
	.byte >(.nomove-1)
	.byte >(.left-1)
	.byte >(.right-1)
	.byte >(.nomove-1)
.d00jumptablelo
	.byte <(.nomove-1)
	.byte <(.left-1)
	.byte <(.right-1)
	.byte <(.nomove-1)
.d01 ; d01 on temp1 goto right nomove nomove left

	LDX temp1
	LDA .d01jumptablehi,x
	PHA
	LDA .d01jumptablelo,x
	PHA
	RTS
.d01jumptablehi
	.byte >(.right-1)
	.byte >(.nomove-1)
	.byte >(.nomove-1)
	.byte >(.left-1)
.d01jumptablelo
	.byte <(.right-1)
	.byte <(.nomove-1)
	.byte <(.nomove-1)
	.byte <(.left-1)
.d11 ; d11 on temp1 goto nomove right left nomove

	LDX temp1
	LDA .d11jumptablehi,x
	PHA
	LDA .d11jumptablelo,x
	PHA
	RTS
.d11jumptablehi
	.byte >(.nomove-1)
	.byte >(.right-1)
	.byte >(.left-1)
	.byte >(.nomove-1)
.d11jumptablelo
	.byte <(.nomove-1)
	.byte <(.right-1)
	.byte <(.left-1)
	.byte <(.nomove-1)
.d10 ; d10 on temp1 goto left nomove nomove right

	LDX temp1
	LDA .d10jumptablehi,x
	PHA
	LDA .d10jumptablelo,x
	PHA
	RTS
.d10jumptablehi
	.byte >(.left-1)
	.byte >(.nomove-1)
	.byte >(.nomove-1)
	.byte >(.right-1)
.d10jumptablelo
	.byte <(.left-1)
	.byte <(.nomove-1)
	.byte <(.nomove-1)
	.byte <(.right-1)
.L0222 ;  rem done with reading code

.left ; left carpos = carpos - 1 : gamebits{0} = 1

	DEC carpos
	LDA gamebits
	ORA #1
	STA gamebits
.L0223 ;  goto nomove

 jmp .nomove

.right ; right carpos = carpos + 1 : gamebits{0} = 1

	INC carpos
	LDA gamebits
	ORA #1
	STA gamebits
.nomove
 ; nomove

.L0224 ;  last = temp1

	LDA temp1
	STA last
.nodriving
 ; nodriving

.L0225 ;  carpos = carpos  &  15

	LDA carpos
	AND #15
	STA carpos
.
 ; 

.L0226 ;  gosub carFrame

 jsr .carFrame

.
 ; 

.SameFrame
 ; SameFrame

.L0227 ;  COLUP0  =  14

	LDA #14
	STA COLUP0
.L0228 ;  REFP0 = gamebits

	LDA gamebits
	STA REFP0
.L0229 ;  if scadd > 0 then scadd = scadd - 1 : score = score + 1

	LDA #0
	CMP scadd
     BCS .skipL0229
.condpart49
	DEC scadd
	SED
	CLC
	LDA score+2
	ADC #$01
	STA score+2
	LDA score+1
	ADC #$00
	STA score+1
	LDA score
	ADC #$00
	STA score
	CLD
.skipL0229
.
 ; 

.L0230 ;  if !collision(player0,player1) then nohitpikachu

	BIT CXPPMM
 if ((* - .nohitpikachu) < 127) && ((* - .nohitpikachu) > -128)
	bpl .nohitpikachu
 else
	bmi .18skipnohitpikachu
	jmp .nohitpikachu
.18skipnohitpikachu
 endif
.L0231 ;  scadd = scadd + f

	LDA scadd
	CLC
	ADC f
	STA scadd
.L0232 ;  collcount = collcount | 80

	LDA collcount
	ORA #80
	STA collcount
.L0233 ;  if player1x < 16  ||  player1x > 143 then notombstone

	LDA player1x
	CMP #16
 if ((* - .notombstone) < 127) && ((* - .notombstone) > -128)
	bcc .notombstone
 else
	bcs .19skipnotombstone
	jmp .notombstone
.19skipnotombstone
 endif
	LDA #143
	CMP player1x
 if ((* - .notombstone) < 127) && ((* - .notombstone) > -128)
	bcc .notombstone
 else
	bcs .20skipnotombstone
	jmp .notombstone
.20skipnotombstone
 endif
.L0234 ;  temp1 =  ( player1x - 16 )  / 4 : temp2 =  ( player1y - 4 )  / 8

; complex statement detected
	LDA player1x
	SEC
	SBC #16
	lsr
	lsr
	STA temp1
; complex statement detected
	LDA player1y
	SEC
	SBC #4
	lsr
	lsr
	lsr
	STA temp2
.L0235 ;  pfpixel temp1 temp2 on

	LDA temp1
	LDY temp2
	LDX #0
 jsr pfpixel
.notombstone
 ; notombstone

.L0236 ;  player1x = rand & 63 + 48 : if player1x{0} then player1y = 0 else player1y = 90

; complex statement detected
 jsr randomize
	PHA
	LDA #63
	CLC
	ADC #48
	TSX
	INX
	TXS
	AND $100,x
	STA player1x
	LDA player1x
	LSR
	BCC .skipL0236
.condpart50
	LDA #0
	STA player1y
 jmp .skipelse14
.skipL0236
	LDA #90
	STA player1y
.skipelse14
.
 ; 

.nohitpikachu
 ; nohitpikachu

.L0237 ;  if gamebits{4} then insidewall

	LDA gamebits
	AND #16
 if ((* - .insidewall) < 127) && ((* - .insidewall) > -128)
	BNE .insidewall
 else
	beq .21skipinsidewall
	jmp .insidewall
.21skipinsidewall
 endif
.L0238 ;  if collcount > 16 then hitwall

	LDA #16
	CMP collcount
 if ((* - .hitwall) < 127) && ((* - .hitwall) > -128)
	bcc .hitwall
 else
	bcs .22skiphitwall
	jmp .hitwall
.22skiphitwall
 endif
.L0239 ;  if !collision(player0,playfield) then insidewall

	BIT CXP0FB
 if ((* - .insidewall) < 127) && ((* - .insidewall) > -128)
	bpl .insidewall
 else
	bmi .23skipinsidewall
	jmp .insidewall
.23skipinsidewall
 endif
.L0240 ;  if !switchleftb then velocity = 0

 lda #$40
 bit SWCHB
	BEQ .skipL0240
.condpart51
	LDA #0
  ASL
  ASL
  ASL
  ASL
	STA velocity
.skipL0240
.L0241 ;  gamebits{4} = 1 : collcount = collcount  |  96 : collcount{3} = 0 : goto hitwall

	LDA gamebits
	ORA #16
	STA gamebits
	LDA collcount
	ORA #96
	STA collcount
	LDA collcount
	AND #247
	STA collcount
 jmp .hitwall

.insidewall
 ; insidewall

.L0242 ;  if !collision(player0,playfield) then gamebits{4} = 0 : goto hitwall

	BIT CXP0FB
	BMI .skipL0242
.condpart52
	LDA gamebits
	AND #239
	STA gamebits
 jmp .hitwall

.skipL0242
.L0243 ;  if velocity > 16 then velocity = velocity - 0.1875

	LDA #16
	CMP velocity
     BCS .skipL0243
.condpart53
	SEC
	LDA velocity
	SBC #3
	STA velocity
.skipL0243
.
 ; 

.hitwall
 ; hitwall

.L0244 ;  drawscreen

 jsr drawscreen
.
 ; 

.L0245 ;  goto startLoop

 jmp .startLoop

.
 ; 

.
 ; 

.carFrame
 ; carFrame

.
 ; 

.
 ; 

.L0246 ;  carframe  =  0

	LDA #0
	STA carframe
.L0247 ;  if carpos  <  9 then carframe  =  carpos  :  gamebits{3} =  0

	LDA carpos
	CMP #9
     BCS .skipL0247
.condpart54
	LDA carpos
	STA carframe
	LDA gamebits
	AND #247
	STA gamebits
.skipL0247
.L0248 ;  if carpos  >=  9 then carframe  =  16  -  carpos  :  gamebits{3}  =  1

	LDA carpos
	CMP #9
     BCC .skipL0248
.condpart55
	LDA #16
	SEC
	SBC carpos
	STA carframe
	LDA gamebits
	ORA #8
	STA gamebits
.skipL0248
.
 ; 

.
 ; 

.
 ; 

.
 ; 

.L0249 ;  on carframe goto 5 10 20 30 40 50 60 70 80

	LDX carframe
	LDA .L0249jumptablehi,x
	PHA
	LDA .L0249jumptablelo,x
	PHA
	RTS
.L0249jumptablehi
	.byte >(.5-1)
	.byte >(.10-1)
	.byte >(.20-1)
	.byte >(.30-1)
	.byte >(.40-1)
	.byte >(.50-1)
	.byte >(.60-1)
	.byte >(.70-1)
	.byte >(.80-1)
.L0249jumptablelo
	.byte <(.5-1)
	.byte <(.10-1)
	.byte <(.20-1)
	.byte <(.30-1)
	.byte <(.40-1)
	.byte <(.50-1)
	.byte <(.60-1)
	.byte <(.70-1)
	.byte <(.80-1)
.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.5 ; 5 player0:

	LDA #<player5_0

	STA player0pointerlo
	LDA #>player5_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0250 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.10 ; 10 player0:

	LDA #<player10_0

	STA player0pointerlo
	LDA #>player10_0

	STA player0pointerhi
	LDA #9
	STA player0height
.L0251 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.20 ; 20 player0:

	LDA #<player20_0

	STA player0pointerlo
	LDA #>player20_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0252 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.30 ; 30 player0:

	LDA #<player30_0

	STA player0pointerlo
	LDA #>player30_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0253 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.40 ; 40 player0:

	LDA #<player40_0

	STA player0pointerlo
	LDA #>player40_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0254 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.50 ; 50 player0:

	LDA #<player50_0

	STA player0pointerlo
	LDA #>player50_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0255 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.60 ; 60 player0:

	LDA #<player60_0

	STA player0pointerlo
	LDA #>player60_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0256 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.70 ; 70 player0:

	LDA #<player70_0

	STA player0pointerlo
	LDA #>player70_0

	STA player0pointerhi
	LDA #8
	STA player0height
.L0257 ;  goto doneSetFrame

 jmp .doneSetFrame

.
 ; 

.80 ; 80 player0:

	LDA #<player80_0

	STA player0pointerlo
	LDA #>player80_0

	STA player0pointerhi
	LDA #8
	STA player0height
.doneSetFrame
 ; doneSetFrame

.
 ; 

.L0258 ;  return

	RTS
.
 ; 

.movepikachu
 ; movepikachu

.L0259 ;  temp1 = pikachuxvel & 252 : temp2 = pikachuyvel & 252 : temp3 = pikachufinalxvel & 252 : temp4 = pikachufinalyvel & 252

	LDA pikachuxvel
	AND #252
	STA temp1
	LDA pikachuyvel
	AND #252
	STA temp2
	LDA pikachufinalxvel
	AND #252
	STA temp3
	LDA pikachufinalyvel
	AND #252
	STA temp4
.L0260 ;  if temp1 <> temp3 then check80

	LDA temp1
	CMP temp3
 if ((* - .check80) < 127) && ((* - .check80) > -128)
	BNE .check80
 else
	beq .24skipcheck80
	jmp .check80
.24skipcheck80
 endif
.L0261 ;  pikachufinalxvel = rand

 jsr randomize
	STA pikachufinalxvel
.L0262 ;  if level{1} then temp1 = player1x - player0x : pikachufinalxvel{7} = temp1{7}

	LDA level
	AND #2
	BEQ .skipL0262
.condpart56
	LDA player1x
	SEC
	SBC player0x
	STA temp1
	LDA temp1
	AND #128
  PHP
	LDA pikachufinalxvel
  PLP
	.byte $D0, $03
	AND #127
	.byte $0C
	ORA #128
	STA pikachufinalxvel
.skipL0262
.check80
 ; check80

.L0263 ;  if temp2 <> temp4 then donecheck24

	LDA temp2
	CMP temp4
 if ((* - .donecheck24) < 127) && ((* - .donecheck24) > -128)
	BNE .donecheck24
 else
	beq .25skipdonecheck24
	jmp .donecheck24
.25skipdonecheck24
 endif
.L0264 ;  pikachufinalyvel = rand

 jsr randomize
	STA pikachufinalyvel
.L0265 ;  if level{1} then temp1 = player1y - player0y : pikachufinalyvel{7} = temp1{7}

	LDA level
	AND #2
	BEQ .skipL0265
.condpart57
	LDA player1y
	SEC
	SBC player0y
	STA temp1
	LDA temp1
	AND #128
  PHP
	LDA pikachufinalyvel
  PLP
	.byte $D0, $03
	AND #127
	.byte $0C
	ORA #128
	STA pikachufinalyvel
.skipL0265
.donecheck24
 ; donecheck24

.L0266 ;  if pikachuxvel{7}  &&  !pikachufinalxvel{7} then pikachuxvel = pikachuxvel + 1 : goto donex

	BIT pikachuxvel
	BPL .skipL0266
.condpart58
	BIT pikachufinalxvel
	BMI .skip58then
.condpart59
	INC pikachuxvel
 jmp .donex

.skip58then
.skipL0266
.L0267 ;  if !pikachuxvel{7}  &&  pikachufinalxvel{7} then pikachuxvel = pikachuxvel - 1 : goto donex

	BIT pikachuxvel
	BMI .skipL0267
.condpart60
	BIT pikachufinalxvel
	BPL .skip60then
.condpart61
	DEC pikachuxvel
 jmp .donex

.skip60then
.skipL0267
.L0268 ;  if pikachuxvel > pikachufinalxvel then pikachuxvel = pikachuxvel - 1 else pikachuxvel = pikachuxvel + 1

	LDA pikachufinalxvel
	CMP pikachuxvel
     BCS .skipL0268
.condpart62
	DEC pikachuxvel
 jmp .skipelse15
.skipL0268
	INC pikachuxvel
.skipelse15
.donex
 ; donex

.L0269 ;  if pikachuyvel{7}  &&  !pikachufinalyvel{7} then pikachuyvel = pikachuyvel + 1 : goto doney

	BIT pikachuyvel
	BPL .skipL0269
.condpart63
	BIT pikachufinalyvel
	BMI .skip63then
.condpart64
	INC pikachuyvel
 jmp .doney

.skip63then
.skipL0269
.L0270 ;  if !pikachuyvel{7}  &&  pikachufinalyvel{7} then pikachuyvel = pikachuyvel - 1 : goto doney

	BIT pikachuyvel
	BMI .skipL0270
.condpart65
	BIT pikachufinalyvel
	BPL .skip65then
.condpart66
	DEC pikachuyvel
 jmp .doney

.skip65then
.skipL0270
.L0271 ;  if pikachuyvel > pikachufinalyvel then pikachuyvel = pikachuyvel - 1 else pikachuyvel = pikachuyvel + 1

	LDA pikachufinalyvel
	CMP pikachuyvel
     BCS .skipL0271
.condpart67
	DEC pikachuyvel
 jmp .skipelse16
.skipL0271
	INC pikachuyvel
.skipelse16
.doney
 ; doney

.L0272 ;  temp5 = 0

	LDA #0
	STA temp5
.L0273 ;  if pikachuxvel{7} then temp5 = 255

	BIT pikachuxvel
	BPL .skipL0273
.condpart68
	LDA #255
	STA temp5
.skipL0273
.L0274 ;  temp3 = 0

	LDA #0
	STA temp3
.L0275 ;  if pikachuyvel{7} then temp3 = 255

	BIT pikachuyvel
	BPL .skipL0275
.condpart69
	LDA #255
	STA temp3
.skipL0275
.L0276 ;  temp6 = pikachuxvel : temp4 = pikachuyvel

	LDA pikachuxvel
	STA temp6
	LDA pikachuyvel
	STA temp4
.L0277 ;  pikachuxpos = pikachuxpos + pikachuvel

	LDA v
	CLC 
	ADC temp6
	STA v
	LDA pikachuxpos
	ADC pikachuvel
	STA pikachuxpos
.L0278 ;  temp6 = temp4 : temp5 = temp3

	LDA temp4
	STA temp6
	LDA temp3
	STA temp5
.L0279 ;  pikachuypos = pikachuypos + pikachuvel

	LDA w
	CLC 
	ADC temp6
	STA w
	LDA pikachuypos
	ADC pikachuvel
	STA pikachuypos
.L0280 ;  if player1y > 100 then player1y = 0

	LDA #100
	CMP player1y
     BCS .skipL0280
.condpart70
	LDA #0
	STA player1y
.skipL0280
.L0281 ;  if player1y > $50 then pikachufinalyvel =  ( pikachufinalyvel ^ 127 )  | 128 : pikachuyvel =  ( pikachuyvel ^ 127 )  | 128

	LDA #$50
	CMP player1y
     BCS .skipL0281
.condpart71
; complex statement detected
	LDA pikachufinalyvel
	EOR #127
	ORA #128
	STA pikachufinalyvel
; complex statement detected
	LDA pikachuyvel
	EOR #127
	ORA #128
	STA pikachuyvel
.skipL0281
.L0282 ;  if player1y < 10 then pikachufinalyvel =  ( pikachufinalyvel ^ 127 )  & 127 : pikachuyvel =  ( pikachuyvel ^ 127 )  & 127

	LDA player1y
	CMP #10
     BCS .skipL0282
.condpart72
; complex statement detected
	LDA pikachufinalyvel
	EOR #127
	AND #127
	STA pikachufinalyvel
; complex statement detected
	LDA pikachuyvel
	EOR #127
	AND #127
	STA pikachuyvel
.skipL0282
.L0283 ;  if player1x > 200 then player1x = player1x + 160

	LDA #200
	CMP player1x
     BCS .skipL0283
.condpart73
	LDA player1x
	CLC
	ADC #160
	STA player1x
.skipL0283
.L0284 ;  if player1x > 160 then player1x = player1x - 160

	LDA #160
	CMP player1x
     BCS .skipL0284
.condpart74
	LDA player1x
	SEC
	SBC #160
	STA player1x
.skipL0284
.L0285 ;  REFP1 = pikachuxvel / 16

	LDA pikachuxvel
	lsr
	lsr
	lsr
	lsr
	STA REFP1
.L0286 ;  return

	RTS
.
 ; 

.L0287 ;  data gonextlevel

	JMP .skipL0287
gonextlevel
	.byte  1,2,3,4,5,6,7,8,9,$10,$11,$12,$13,$14,$15,$99

.skipL0287
.
 ; 

.L0288 ;  vblank

vblank_bB_code
.L0289 ;  if gamebits{7}  &&  level{0} then gosub movepikachu

	BIT gamebits
	BPL .skipL0289
.condpart75
	LDA level
	LSR
	BCC .skip75then
.condpart76
 jsr .movepikachu

.skip75then
.skipL0289
.L0290 ;  return

	RTS
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player0then_1

	.byte 0
	.byte         %00100100
	.byte         %00011000
	.byte         %00011000
	.byte         %00111100
	.byte         %00100100
	.byte         %00011000
	.byte         %00100100
	.byte         %01000010
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player1then_1

	.byte 0
	.byte         %00100100
	.byte         %00011000
	.byte         %00011000
	.byte         %00111100
	.byte         %00100100
	.byte         %00011000
	.byte         %00100100
	.byte         %01000010
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
playercolorL056_1

	.byte 0
	.byte  32
	.byte  30
	.byte  30
	.byte  30
	.byte  64
	.byte  30
	.byte  30
	.byte  30
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player5_0

	.byte 0
	.byte   %11000011
	.byte   %11111111
	.byte   %11011011
	.byte   %00011000
	.byte   %11011011
	.byte   %11111111
	.byte   %11011011
	.byte   %00011000
 if (<*) > (<(*+10))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player10_0

	.byte 0
	.byte  %00000110
	.byte  %00111110
	.byte  %11110000
	.byte  %11011011
	.byte  %00011111
	.byte  %11111000
	.byte  %11001100
	.byte  %00000100
	.byte 
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player20_0

	.byte 0
	.byte  %00001100
	.byte  %00001100
	.byte  %00110011
	.byte  %00111011
	.byte  %11011100
	.byte  %11001100
	.byte  %00110010
	.byte  %00110000
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player30_0

	.byte 0
	.byte  %00110110
	.byte  %00110110
	.byte  %01100100
	.byte  %01111110
	.byte  %01011110
	.byte  %11001011
	.byte  %11011000
	.byte  %00011000
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player40_0

	.byte 0
	.byte  %11101110
	.byte  %11101110
	.byte  %01000100
	.byte  %01111111
	.byte  %01111111
	.byte  %01000100
	.byte  %11101110
	.byte  %11101110
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player50_0

	.byte 0
	.byte  %00011000
	.byte  %11011000
	.byte  %11001011
	.byte  %01011110
	.byte  %01111110
	.byte  %01100100
	.byte  %00110110
	.byte  %00110110
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player60_0

	.byte 0
	.byte  %00110000
	.byte  %00110010
	.byte  %11001100
	.byte  %11011100
	.byte  %00111011
	.byte  %00110011
	.byte  %00001100
	.byte  %00001100
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player70_0

	.byte 0
	.byte  %00000100
	.byte  %11001100
	.byte  %11111000
	.byte  %00011111
	.byte  %11011011
	.byte  %11110000
	.byte  %00111110
	.byte  %00000110
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
player80_0

	.byte 0
	.byte   %00011000
	.byte   %11011011
	.byte   %11111111
	.byte   %11011011
	.byte   %00011000
	.byte   %11011011
	.byte   %11111111
	.byte   %11000011
       echo "    ",[(scoretable - *)]d , "bytes of ROM space left")
 
 
 
